unit welcomeform;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, formpanel,
  FramView, LCLType, LCLIntf,  HtmlGlobals;

type

  { TWelcomePanel }

  TWelcomePanel = class(TFormPanel)
  public
    procedure ShowForm;override;
  end;

  { TfrmWelcome }

  TfrmWelcome = class(TForm)
    Html: TFrameViewer;
    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure HtmlHotSpotTargetClick(Sender: TObject; const Target,
      URL: ThtString; var Handled: boolean);
  private

  public

  end;

implementation

{$R *.frm}

{ TWelcomePanel }

procedure TWelcomePanel.ShowForm;
var
  mform:TfrmWelcome;
begin
  inherited ShowForm;
  mform:=TfrmWelcome.Create(Self);
  mform.Parent:=Self;
  mform.Align:=alClient;
  mform.Show;
end;

{ TfrmWelcome }

procedure TfrmWelcome.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
  html.Free;
  CloseAction:=caFree;
end;

procedure TfrmWelcome.FormShow(Sender: TObject);
var
  mStream:TStringStream;
  mRes:TResourceStream;
begin
  //从资源中读取
  mRes:=TResourceStream.Create(HInstance,'WELCOME',RT_RCDATA);
  mStream:=TStringStream.Create('',TEncoding.UTF8);
  mRes.SaveToStream(mStream);
  html.LoadFromString(mStream.DataString);
  mStream.Free;
  mRes.Free;
end;

procedure TfrmWelcome.HtmlHotSpotTargetClick(Sender: TObject; const Target,
  URL: ThtString; var Handled: boolean);
begin
  OpenDocument(Url);
  Handled:=True;
end;

end.

